Spot-On
spot-on-common.h
1 /*
2 ** Copyright (c) 2011 - 10^10^10, Alexis Megas.
3 ** All rights reserved.
4 **
5 ** Redistribution and use in source and binary forms, with or without
6 ** modification, are permitted provided that the following conditions
7 ** are met:
8 ** 1. Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
10 ** 2. Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
13 ** 3. The name of the author may not be used to endorse or promote products
14 ** derived from Spot-On without specific prior written permission.
15 **
16 ** SPOT-ON IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 ** SPOT-ON, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef _spoton_common_h_
29 #define _spoton_common_h_
30 
31 extern "C"
32 {
33 #include <limits.h>
34 }
35 
36 #include <QHash>
37 #include <QStringList>
38 
39 typedef QHash<QString, QByteArray> QStringByteArrayHash;
40 typedef QList<QByteArray> QByteArrayList;
41 typedef QList<QPair<QByteArray, qint64> > QPairByteArrayInt64List;
42 typedef QPair<QByteArray, QByteArray> QPairByteArrayByteArray;
43 
45 {
46  public:
47  static QList<int> LANE_WIDTHS;
48  static QString POSTGRESQL_CONNECTION_OPTIONS;
49  static QString SSL_CONTROL_STRING;
50  static QStringList ACCEPTABLE_URL_SCHEMES;
51  static QStringList SPOTON_ENCRYPTION_KEY_NAMES;
52  static QStringList SPOTON_SIGNATURE_KEY_NAMES;
53  static const int ACCOUNTS_RANDOM_BUFFER_SIZE = 64;
54  static const int BUZZ_MAXIMUM_ID_LENGTH = 256; /*
55  ** Please use a number
56  ** that's divisible by two.
57  ** The number of random bytes
58  ** to be used is half of this
59  ** number. The actual ID
60  ** will be represented in
61  ** base sixteen.
62  */
63  static const int BUZZ_TIME_DELTA = 30;
64  static const int CACHE_TIME_DELTA_MAXIMUM_STATIC = 30;
65  static const int CHAT_MAXIMUM_REPLAY_QUEUE_SIZE = 15;
66  static const int CHAT_TIME_DELTA_MAXIMUM_STATIC = 30;
67  static const int ELEGANT_STARBEAM_SIZE = 30000;
68  static const int EMAIL_ATTACHMENT_MAXIMUM_SIZE = 10 * 1024 * 1024; // MiB!
69  static const int EPKS_TIME_DELTA = 30;
70  static const int FORWARD_SECRECY_TIME_DELTA_MAXIMUM_STATIC = 30;
71  static const int GEMINI_TIME_DELTA_MAXIMUM_STATIC = 90;
72  static const int HARVEST_POST_OFFICE_LETTERS_INTERVAL = 5;
73  static const int IDENTICAL_CREDENTIALS_ITERATIONS = 5;
74  static const int KERNEL_CERTIFICATE_DAYS_VALID = 7;
75  static const int KERNEL_URL_DISPATCHER_INTERVAL_STATIC = 60;
76  static const int LANE_WIDTH_DEFAULT = 5242880;
77  static const int LANE_WIDTH_MAXIMUM = 20971520;
78  static const int LANE_WIDTH_MINIMUM = 4096;
79  static const int LOG_FILE_MAXIMUM_SIZE = 8 * 1024 * 1024;
80  static const int MAIL_TIME_DELTA_MAXIMUM_STATIC = 90;
81  static const int MAXIMUM_ATTEMPTS_PER_POPTASTIC_POST = 2;
82  static const int MAXIMUM_COPY_KEY_SIZES = 10 * 1024 * 1024;
83  static const int MAXIMUM_DESCRIPTION_LENGTH_SEARCH_RESULTS = 500;
84  static const int MAXIMUM_KERNEL_GUI_SERVER_SINGLE_SOCKET_BUFFER_SIZE =
85 #ifdef SPOTON_MCELIECE_ENABLED
86  INT_MAX;
87 #else
88  CHAR_BIT * 1024 * 1024;
89 #endif
90  static const int MAXIMUM_KERNEL_WEB_SERVER_SOCKET_READ_BUFFER_SIZE = 4096;
91  static const int MAXIMUM_PENDING_CONNECTIONS = USHRT_MAX;
92  static const int MAXIMUM_UDP_DATAGRAM_SIZE = 508;
93  static const int MINIMUM_SECURE_MEMORY_POOL_SIZE = 262144;
94  static const int MINIMUM_STARBEAM_PULSE_SIZE = 1024;
95  static const int MOSAIC_SIZE = 64;
96  static const int NAME_MAXIMUM_LENGTH = 64;
97  static const int NEIGHBOR_LIFETIME_MS = 10 * 60 * 1000;
98  static const int NEIGHBOR_SILENCE_TIME = 180;
99  static const int POPTASTIC_FORWARD_SECRECY_TIME_DELTA_MAXIMUM_STATIC = 60;
100  static const int POPTASTIC_GEMINI_TIME_DELTA_MAXIMUM_STATIC = 90;
101  static const int POPTASTIC_MAXIMUM_EMAIL_SIZE = 50 * 1024 * 1024;
102  static const int POPTASTIC_STATUS_INTERVAL = 60;
103  static const int REAP_POST_OFFICE_LETTERS_INTERVAL = 60;
104  static const int RSS_IMPORTS_PER_THREAD = 5;
105  static const int SEND_QUEUED_EMAIL_INTERVAL = 5;
106  static const int SMP_TIME_DELTA_MAXIMUM = 90;
107  static const int SPOTON_HOME_MAXIMUM_PATH_LENGTH = 256;
108  static const int STARBEAM_TIME_DELTA = 30;
109  static const int STATUS_INTERVAL = 15;
110  static const int STATUS_TEXT_MAXIMUM_LENGTH = 64;
111  static const int URL_CONTENT_SHARE_MAXIMUM_SIZE = 5 * 1024 * 1024;
112  static const int URL_TIME_DELTA = 30;
113  static const int WAIT_FOR_BYTES_WRITTEN_MSECS_MAXIMUM = 2500;
114  static const int WAIT_FOR_BYTES_WRITTEN_MSECS_PREFERRED = 250; /*
115  ** Please
116  ** consider
117  ** changing
118  ** if the
119  ** maximums
120  ** (BLUETOOTH,
121  ** SCTP, TCP,
122  ** UDP) are
123  ** changed.
124  */
125  static const int WEB_SERVER_KEY_SIZE = 3072;
126  static const long int WEB_SERVER_CERTIFICATE_LIFETIME =
127  365L * 60L * 60L * 24L;
128  static const qint64 MAXIMUM_BLUETOOTH_PACKET_SIZE = 1000;
129  static const qint64 MAXIMUM_NEIGHBOR_BUFFER_SIZE =
130  static_cast<qint64> (LANE_WIDTH_MAXIMUM); /*
131  ** The buffer size must be greater
132  ** than the content length.
133  */
134  static const qint64 MAXIMUM_NEIGHBOR_CONTENT_LENGTH =
135  MAXIMUM_NEIGHBOR_BUFFER_SIZE / 10;
136  static const qint64 MAXIMUM_SCTP_PACKET_SIZE = 500;
137  static const qint64 MAXIMUM_STARBEAM_PULSE_SIZE = 2500000;
138  static const qint64 MAXIMUM_TCP_PACKET_SIZE = 4096;
139  static const qint64 MINIMUM_NEIGHBOR_CONTENT_LENGTH = 256;
140  static const unsigned long int GEMINI_ITERATION_COUNT = 25000;
141 
142  /*
143  ** Dynamic values. Not a pleasant solution.
144  */
145 
146  static int CACHE_TIME_DELTA_MAXIMUM;
147  static int CHAT_TIME_DELTA_MAXIMUM;
148  static int FORWARD_SECRECY_TIME_DELTA_MAXIMUM;
149  static int GEMINI_TIME_DELTA_MAXIMUM;
150  static int KERNEL_URL_DISPATCHER_INTERVAL;
151  static int MAIL_TIME_DELTA_MAXIMUM;
152  static int POPTASTIC_FORWARD_SECRECY_TIME_DELTA_MAXIMUM;
153  static int POPTASTIC_GEMINI_TIME_DELTA_MAXIMUM;
154 
155  private:
156  spoton_common(void);
157  ~spoton_common();
158 };
159 
160 #endif
spoton_common
Definition: spot-on-common.h:44